package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.tanhua.domain.db.Question;
import com.tanhua.dubbo.mapper.QuestionMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class QuestionApiImpl implements QuestionApi{

    @Autowired
    private QuestionMapper questionMapper;

    @Override
    public Question findQuestion(Long userId) {
        Question question = questionMapper.selectOne(new LambdaQueryWrapper<Question>().eq(Question::getUserId, userId));
        return question;


    }

    @Override
    public void addQuestions(Question question) {
        questionMapper.insert(question);
    }

    @Override
    public void updateQuestions(Question question) {
        questionMapper.updateById(question);
    }
}
